package com.ten.order.controller;

import com.alipay.api.AlipayApiException;
import com.ten.common.core.vo.Result;
import com.ten.order.service.OrderPayService;
import com.ten.order.service.PayService;
import com.ten.order.vo.AliPayBean;
import io.swagger.annotations.Api;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.logging.Logger;

/**
 * @author ：王薪伟
 * @date ：Created in 2022/12/24 22:04
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/order")
@Api(tags = "订单支付接口类")
public class OrderPayController {

    @Autowired
    private OrderPayService orderPayService;


    @PostMapping("/pay/createWeiXin/{courseId}/{memberId}")
    public Result createWeiXin(@PathVariable String courseId,
                               @PathVariable String memberId) {
        return orderPayService.saveOrder(courseId, memberId);
    }

    @PostMapping("/pay/getPayStatus/{orderNo}")
    public Result getPayStatus(@PathVariable String orderNo) {
        return orderPayService.selectStatus(orderNo);
    }
    /**
     *  
     *
     * @create by:  Q大侠
     * @description: 支付宝支付 
     * @create time: 2023/1/5 22:19
     * @param  
     * @return  
     */
    @Autowired
    private PayService payService;

    @RequestMapping("/pay/allPay/{courseId}/{HuiYuanId}")
    public Result allpay(@PathVariable String courseId,
                         @PathVariable String HuiYuanId) throws AlipayApiException {
        return payService.aliPay(courseId, HuiYuanId);
    }
    @RequestMapping("/pay/myPay")
    public Result myPay(@PathVariable String courseId,
                        @PathVariable String HuiYuanId){
        System.out.println(courseId+":订单已支付");
        return new Result();
    }

}
